#ifndef SQLCONTROLLER_H
#define SQLCONTROLLER_H

#include <QSqlDatabase>
#include <QSqlQueryModel>
#include "config.h"

class SqlController
{
public:
    SqlController();
    static SqlController *getInstance();
    QString strToMd5(QString str);

    bool initDataBase();
    //用户注册登录
    bool goRegister(QString name, QString pwd, int auth = 0);
    bool goLogin(QString name, QString pwd);
    //用户
    UserInfo getUserInfo(QString name);
    bool removeUser(QString name);
    QList<UserInfo> getAllUserInfo();

    //student
    QSqlQueryModel *getStudentModel();

private:
    static SqlController *s_instance;

    QSqlDatabase m_db;
};

#endif // SQLCONTROLLER_H
